<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
      
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNo" label="订单编号">
          <a-input placeholder="请输入订单编号" v-model="model.orderNo" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="simOrderId" label="sim订单号">
          <a-input placeholder="请输入sim订单号" v-model="model.simOrderId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mtBmUid" label="美团⽤户加密ID">
          <a-input placeholder="请输入美团⽤户加密ID" v-model="model.mtBmUid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cardNo" label="身份证号">
          <a-input placeholder="请输入身份证号" v-model="model.cardNo" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cardName" label="姓名">
          <a-input placeholder="请输入姓名" v-model="model.cardName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="goodsName" label="商品名称">
          <a-input placeholder="请输入商品名称" v-model="model.goodsName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="comboName" label="套餐名称">
          <a-input placeholder="请输入套餐名称" v-model="model.comboName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="comboLevel" label="套餐档次">
          <a-input placeholder="请输入套餐档次" v-model="model.comboLevel" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="comboMobile" label="开卡⼿机号">
          <a-input placeholder="请输入开卡⼿机号" v-model="model.comboMobile" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactsMobile" label="联系人手机号">
          <a-input placeholder="请输入联系人手机号" v-model="model.contactsMobile" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactsCity" label="收货地区">
          <a-input placeholder="请输入收货地区" v-model="model.contactsCity" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactsAddress" label="收货详细地址">
          <a-input placeholder="请输入收货详细地址" v-model="model.contactsAddress" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="simOrderTime" label="订单时间">
          <a-input placeholder="请输入订单时间" v-model="model.simOrderTime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="couponId" label="加密券id">
          <a-input placeholder="请输入加密券id" v-model="model.couponId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="activateTime" label="激活时间">
          <a-input placeholder="请输入激活时间" v-model="model.activateTime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status" label="状态">
          <a-input placeholder="请输入状态(0 未提交，1 已提交，2 已完成，-1 已拒绝)" v-model="model.status" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spiStatus" label="运营商状态">
          <a-input placeholder="请输入运营商状态（0：未处理；1：已下单，待激活；2：已激活；其他的为失败）" v-model="model.spiStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="riderStatus" label="骑手状态">
          <a-input placeholder="请输入骑手状态(1表示正常骑⼿，0表示⾮骑⼿，2表示⻛险骑⼿)" v-model="model.riderStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reconciliationStatus" label="对账状态">
          <a-input placeholder="请输入对账状态(0，未对账，1-已对账，2-不存在)" v-model="model.reconciliationStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark" label="备注">
          <a-input placeholder="请输入备注" v-model="model.remark" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="spiDepartId" label="运营商部门">
          <a-input placeholder="请输入运营商部门" v-model="model.spiDepartId" />
        </a-form-model-item>
		
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import moment from "moment"

  export default {
    name: "SimOrderModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        },
        url: {
          add: "/sim/simOrder/add",
          edit: "/sim/simOrder/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        //初始化默认值
        this.edit({});
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
         this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false;
          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>